package com.new2i.action;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.new2i.model.DoctorEntity;
import com.new2i.model.ScreenSchoolEntity;
import com.new2i.service.able.ScreenSchoolService; 
import com.new2i.util.Collection2JsonUtil;

/**
 * 筛查学校相应接口
 * 
 * @since 2015/09/04
 * @author 2i
 *
 */
@Controller
@RequestMapping("api/school")
public class SchoolApiAction extends BaseAction {

	@Autowired
	private transient ScreenSchoolService mScreenSchoolService;

	/**
	 * 创建筛查医生
	 * 
	 * @author 2i
	 * @since 2015/09/22
	 * @param request
	 * @param response
	 * @param scSchool
	 */
	@RequestMapping("/create.action")
	public void createScreenSchool(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenSchoolEntity scSchool) {
		HashMap<String, Object> map = mScreenSchoolService.insertScreenSchool(scSchool);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
	
	/**
	 * 筛查医生列表
	 * 
	 * @author 2i
	 * @since 2015/09/22
	 * @param request
	 * @param response
	 * @param scSchool
	 */
	@RequestMapping("/list.action")
	public void selectScreenSchoolList(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenSchoolEntity scSchool) {
		List<HashMap<String, Object>> list = mScreenSchoolService.selectScreenSchoolList(doctor);
		String value = Collection2JsonUtil.byList(list, "sc_school_list");
		write2client(response, value);
	}
	
	/**
	 * 筛查医生列表
	 * 
	 * @author 2i
	 * @since 2015/09/22
	 * @param request
	 * @param response
	 * @param scSchool
	 */
	@RequestMapping("/info.action")
	public void getScreenSchoolInfo(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenSchoolEntity scSchool) {
		HashMap<String, Object> map = mScreenSchoolService.getScreenSchoolById(scSchool);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
	

	
	/**
	 * 修改筛查医生
	 * 
	 * @author 2i
	 * @since 2015/09/22
	 * @param request
	 * @param response
	 * @param scSchool
	 */
	@RequestMapping("/update.action")
	public void updateScreenSchool(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenSchoolEntity scSchool) {
		HashMap<String, Object> map = mScreenSchoolService.updateScreenSchool(scSchool);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
	
	/**
	 * 已移除（软删除）筛查医生
	 * 
	 * @author 2i
	 * @since 2015/09/24
	 * @param request
	 * @param response
	 * @param scSchool
	 */
	@RequestMapping("/remove.action")
	public void removeScreenSchool(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenSchoolEntity scSchool) {
		HashMap<String, Object> map = mScreenSchoolService.removeScreenSchool(scSchool);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
	
	
	/**
	 * 删除筛查学校
	 * 
	 * @author 2i
	 * @since 2015/09/24
	 * @param request
	 * @param response
	 * @param scSchool
	 */
	@RequestMapping("/delete.action")
	public void deleteScreenSchoolList(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenSchoolEntity scSchool) {
		HashMap<String, Object> map = mScreenSchoolService.deleteScreenSchool(scSchool);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
}
